/**
 * 
 */
package com.msoe.client.panels;

import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author finleyb
 * a static message class
 */
public class MessageBox {

	/**
	 * creates a MessageBox with the specified
	 * title and message
	 * @param Title the title of the MessageBox
	 * @param message the message of the MessageBox
	 */
	public static void showMessageDialog(String Title,String message) {
		// Create a dialog box and set the caption text
		final DialogBox dialogBox = new DialogBox();
		dialogBox.setText(Title);

		// Create a table to layout the content
		VerticalPanel dialogContents = new VerticalPanel();
		dialogContents.setSpacing(4);
		dialogBox.setWidget(dialogContents);

		Label messageLabel = new Label(message);
		dialogContents.add(messageLabel);
		
		// Add a close button at the bottom of the dialog
		Button closeButton = new Button("Close",
				new ClickListener() {
			public void onClick(Widget sender) {
				dialogBox.hide();
			}
		});
		dialogContents.add(closeButton);
		if (LocaleInfo.getCurrentLocale().isRTL()) {
			dialogContents.setCellHorizontalAlignment(closeButton,
					HasHorizontalAlignment.ALIGN_LEFT);

		} else {
			dialogContents.setCellHorizontalAlignment(closeButton,
					HasHorizontalAlignment.ALIGN_RIGHT);
		}

		dialogBox.setAnimationEnabled(true);
		dialogBox.center();
		dialogBox.show();
	}
	
	
}


